package com.gsm.controller;

import com.gsm.entity.RotationChart;
import com.gsm.service.RotationChartService;
import com.gsm.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 轮播图(RotationChart)表控制层
 *
 * @author wjq
 * @since 2020-04-26 22:45:40
 */
@RestController
@RequestMapping("chart")
public class RotationChartController {
    @Autowired
    private RotationChartService rotationChartService;
    
    /**
     * 新增
     */
    @PostMapping("chart")
    public Result insertRotationChart(@RequestBody RotationChart rotationChart) {
        Result result = rotationChartService.insertRotationChart(rotationChart);
        return result;
    }
    
    /**
     * 根据 id 删除数据
     */
    @DeleteMapping("chart/{chartId}")
    public Result deleteRotationChartByChartId(@PathVariable("chartId")Long chartId) {
        Result result = rotationChartService.deleteRotationChartByChartId(chartId);
        return result;
    }

    /**
     * 根据 id 修改单条数据
     */
    @PutMapping("chart/{chartId}")
    public Result updateRotationChartByChartId(@PathVariable("chartId")Long chartId, @RequestBody RotationChart rotationChart) {
        rotationChart.setChartId(chartId);
        Result result = rotationChartService.updateRotationChartByChartId(rotationChart);
        return result;
    }

    /**
     * 根据批量更新
     */
    @PutMapping("charts")
    public Result updateRotationCharts(@RequestBody List<RotationChart> charts) {
        Result result = rotationChartService.updateRotationCharts(charts);
        return result;
    }

    /**
     * 根据 id 查询单条数据
     */
    @GetMapping("chart/{chartId}")
    public Result selectRotationChartByChartId(@PathVariable("chartId")Long chartId) {
        Result result = rotationChartService.selectRotationChartByChartId(chartId);
        return result;
    }
    
    /**
     * 根据条件查询 List
     */
    @GetMapping("chartList")
    public Result selectRotationChartList(RotationChart rotationChart) {
        Result result = rotationChartService.selectRotationChartList(rotationChart);
        return result;
    }
}